package com.qf.dao;

import com.qf.pojo.User;


import com.qf.util.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * @author LiXuekai on 2022/5/21
 */
public class UserDaoImpl implements UserDao {
    //创建Dbutil 工具池
   private   QueryRunner queryRunner=new QueryRunner(DBUtil.getDateSource());
    @Override
    public User findByUserName(String userName) {
        String sql="select * from tb_user where username=？";

        try {
            User   user = queryRunner.query(sql,new BeanHandler<User>(User.class),userName);
            return user;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}